//__UNI__1D92AF2
import Vue from 'vue'
import App from './App'

Vue.config.productionTip = false
import uView from '@/uni_modules/uview-ui'
import utils from './common/utils.js'
Vue.prototype.utils = utils;
// 注册全局组件  分页组件 https://ext.dcloud.net.cn/plugin?id=343
import MescrollBody from "@/components/mescroll-uni/mescroll-body.vue"
import MescrollUni from "@/components/mescroll-uni/mescroll-uni.vue"
Vue.component('mescroll-body', MescrollBody)
Vue.component('mescroll-uni', MescrollUni)

import dropdown from '@/components/dt-dropdown/dt-dropdown.vue'
Vue.component('dropdown', dropdown)


import baseConfig from '@/config/config.js'


import mixinsConfig from '@/mixins/config.js'

Vue.mixin(mixinsConfig)

Vue.use(uView)
Vue.prototype.baseConfig = baseConfig;
Vue.prototype.to = (url) => {
    console.log(9999, url);
    uni.navigateTo({
        url: url
    })
}
Vue.prototype.toast = (title) => {
    uni.showToast({
        title,
        icon: 'none'
    });
}
Vue.prototype.setS = (...arr) => {
    if (arr.length % 2) {
        arr.pop()
    }
    for (let i = 0; i < arr.length - 1; i += 2) {

        if (arr[i].indexOf('.') > 0) { //修改参数
            let o = arr[i].split('.')[0]
            let k = arr[i].split('.')[1]
            let obj = app.getS(o)
            if (obj && Object.prototype.toString.call(obj) === '[object Object]') {
                obj[k] = arr[i + 1]
                app.setS(o, obj)
            } else {
                app.setS(o, { k: arr[i + 1] })
            }

        } else {
            uni.setStorageSync(arr[i], arr[i + 1]);
        }
    }
}
Vue.prototype.getS = (...args) => {
    let k = args[0]
    let v = args[1]
    let res = uni.getStorageSync(k);
    if (args.length > 1) app.setS(k, v)

    return res
}


App.mpType = 'app'

const app = new Vue({
    ...App
})
app.$mount()